package com.briup.app02.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.app02.bean.BaseConfig;
import com.briup.app02.service.IBaseConfigService;
import com.briup.app02.utils.Message;
import com.briup.app02.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/baseconfig")
@Api(description = "系统配置表相关接口")
public class BaseConfigController {
	@Autowired
	private IBaseConfigService baseconfigService;
	
	@GetMapping("query")
	@ApiOperation("查询所有系统配置表信息")
	public Message query(String name){
		List<BaseConfig> list = baseconfigService.query(name);
		return MessageUtil.success(list);
		
	}
	
	@DeleteMapping("deleteById")
	@ApiOperation("根据id删除系统配置表信息")
	@ApiImplicitParams({
		@ApiImplicitParam(name="id",value = "系统配置表id",dataType = "long",paramType = "query",required = true)
	})
	public Message deleteById(@NonNull Long id) {
		baseconfigService.deleteById(id);
		return MessageUtil.success("删除成功") ;
	}
	
	
	@ApiOperation(value="保存或更新系统配置信息")
	@ApiImplicitParams({
		@ApiImplicitParam(name="id",value="序号",paramType="form"),
		@ApiImplicitParam(name="name",value="主键",paramType="form",required=true),
		@ApiImplicitParam(name="val",value="详情",paramType="form"),
		@ApiImplicitParam(name="introduce",value="名称",paramType="form"),
	})
	
	@PostMapping("saveOrUpdate")
	public Message saveOrUpdate(BaseConfig baseconfig) {
		baseconfigService.saveOrUpdate(baseconfig);
		return MessageUtil.success("操作成功");
	}
	
	

}
